package com.itfreer.gis.map.style;

import com.alibaba.dubbo.config.annotation.Service;
import com.itfreer.form.api.BaseDao;
import com.itfreer.form.api.DictionaryServiceImp;
import com.itfreer.form.api.dictionary.DictionaryEntity;
import com.itfreer.gis.map.style.dao.MapStyleSpriteDao;
import com.itfreer.gis.map.style.entity.MapStyleSpriteEntity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定义我的雪碧图目录实现类
 */
@Component
@Service(interfaceClass = MapStyleSpriteService.class, path = "gismapstylesprite")
public class MapStyleSpriteServiceImp extends DictionaryServiceImp<MapStyleSpriteEntity>
		implements MapStyleSpriteService {

	@Autowired
	private MapStyleSpriteDao dao;

	@Override
	protected BaseDao<MapStyleSpriteEntity> getDao() {
		return dao;
	}

	@Override
	public String getDictionaryName() {
		return "p_sprite_directory";
	}

	@Override
	protected DictionaryEntity convert(MapStyleSpriteEntity entity) {
		DictionaryEntity toEntity = new DictionaryEntity();
		toEntity.setDisplay(entity.getName());
		toEntity.setId(entity.getId());
		toEntity.setCode(entity.getId());
		toEntity.setOrder(entity.getOrder());
		toEntity.setLeaf(true);
		toEntity.getOther().put("sprite", entity.getSprite());
		return toEntity;
	}

	@Override
	protected String getDictionaryFields() {
		return "*";
	}
}
